<?php
if (!defined('WEB_ROOT')) {
	exit;
}
if (isset($_GET['id']) && $_GET['id'] >0) {
	$id = $_GET['id'];
	$queryString = "&id=$id";
} /*else {
	$id = 0;
	$queryString = '';
}*/

// how many rows to show per page
$rowsPerPage = 5;

/*$sql = "SELECT maht, chude, noidung, hotentg, tendv
        FROM tacgia tg, seminar se, donvi dv
		WHERE se.tg_id = tg.id and  se.dv_id = dv.id
		ORDER BY se.id desc";*/

$sql = "SELECT se.id, maht, tenht, chude, date_format(ngaythuchien,'%d-%m-%Y') as ngaythuchien, se.diadiem, tendv, lht.tenloai, dv_id
		FROM hoithao se
		LEFT JOIN donvi dv ON se.dv_id = dv.id
		LEFT JOIN loaihoithao lht ON se.loaiht_id = lht.id
		WHERE se.hieu_luc > 0
		ORDER BY se.id desc";

$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
		
?> 
<div class="onecolumn">
				<div class="header">
					<span>Hội thảo</span>
					<div class="switch" style="width:140px">
						<table width="140px" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<td>
									<input name="btnAddSeminar" class="middle_switch" type="button" id="btnAddSeminar" value="Thêm hội thảo"  style="width:140px" onClick="addSeminar()">
								</td>
							</tr>
						</tbody>
						</table>
					</div>
				</div>
				<br class="clear"/>
				<div class="content">
<form action="processSeminar.php?action=addSeminar" method="post"  name="frmListSeminar" id="frmListSeminar">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="data">
	  <tr align="center" id="listTableHeader"> 
		   <th>Thông tin hội thảo</th>
		   <th>Thời gian/Địa điểm</th>
		   <th>Đơn vị</th>
	  </tr>
  <?php
if (dbNumRows($result) > 0) {
	$i = 0;
	while($row = dbFetchAssoc($result)) {
		extract($row);
		if ($i%2) {
			$class = 'row1';
		} else {
			$class = 'row2';
		}
		
		$i += 1;
?>
  <tr class="<?php echo $class; ?>"> 
			<td width="45%">
				<div class="info_detail_noimage">
					<ul>
						<li>Mã hội thảo: &nbsp;<strong><?php echo $maht; ?></strong></li>
						<li>Tên hội thảo: &nbsp;<strong><a href="index.php?view=detail&id=<?php echo $id; ?>"><?php echo $tenht; ?></strong></a></li>
						<li>Chủ đề:&nbsp;<strong><?php echo $chude; ?></strong></li>
					</ul>
					<div class='action'>&nbsp;&nbsp;<a href="javascript:modifySeminar(<?php echo $id; ?>);">Sửa</a>&nbsp;&nbsp;|&nbsp;&nbsp;
						<a href="javascript:deleteSeminar(<?php echo $id; ?>);">Xóa</a></div>
					</div>
			</td>
			<td width="21%">
					<div>&nbsp;Thời gian:&nbsp;<b><?php echo $ngaythuchien; ?></b></div>
					<div>&nbsp;Địa điểm:&nbsp;<b><?php echo $diadiem; ?></b></div>
			</td>
			<td width="34%px">
					<div>&nbsp;Đơn vị:&nbsp;<b><?php echo $tendv; ?></b></div>
			</td>
	</tr>
  <?php
	} // end while
?>
  <tr> 
   <td colspan="5" align="center">
   <?php 
echo $pagingLink;
   ?></td>
  </tr>
<?php	
} else {
?>
  <tr> 
   <td colspan="5" align="center">Không có seminar nào</td>
  </tr>
  <?php
}
?>
 </table>
 <p>&nbsp;</p>
</form>